-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(StakeManager): optimize stake, account init and lock function #130
Conversation
Changes look good to me, but it seems this is not passing tests |
Updated description to explain exactly whats happening here, why this tests are failing for this correct code change. |
22db53b
to
353a4ff
Compare
353a4ff
to
978b4dc
Compare
So this PR is failing on verify because the spec is outdated. Two things are failing:
|
ff243e7
to
ad6328d
Compare
28881ec
to
41b4362
Compare
@3esmit I added a commit here with these changes:
This should do the trick |
c2a4851
to
254ea0a
Compare
…ving mintBonusMP function
change The rule is failing since we've removed the `lockUntil > 0` check in `stake` and `processAccount` is no longer used in `stake()`. The rule requires `lockUntil > 0` so it will always fail there and can't find a non-reverting cases (which makes the rule pass). The reason it hasn't happened before was because: The rule required account.lockUntil > 0 Stake required lockUntil > 0 || account balance == 0 Also this commit adds an invariant: add invariant that account balance == 0 => accountMP == 0
… current sumOfMultipliers
This invariant failed as the prover started making wrong assumptions about the relationship between anyone's account's `totalMP` and its `balance`, as well as an account's `bonusMP` and its `balance`. This commit fixes it by adding the necessary invariants to proof the property.
254ea0a
to
e5d9a45
Compare
Description
This pull request focuses solely on cleaning up the code. The clean-up removes outdated or unnecessary code, which was masking a bug that is being addressed in #127
Details
This changes the account initialization on stake():
lockUntil != 0
This changes the method lock():
Details on #127 bug
The bug was hidden because the _mintBonusMP function contained a line that updated account.lastMint to the same value as startEpoch. This had the unintended effect of making the epoch estimation appear correct when calling StakeManager.lock(). As a result, the underlying bug wasn’t detected in
test_UpdateLockupPeriod
.PR #130 does not fix this bug; instead, it cleans up the code that was hiding it for
test_UpdateLockupPeriod
to cach it. The actual bug fix is handled in PR #127, which also introduces other tests that would have catched it while implementing the multiplier points estimation.Purpose
Code Cleanup: This PR removes code that was masking the bug, allowing the system to function properly moving forward.
Not a Bug Fix: It doesn't directly fix the bug but removes the part of the code that was preventing the issue from being caught in the test.
Important Notes
The test failures seen in executeAccount->processAccount->mintMP are unrelated to this cleanup. However, PR #130 requires that PR #127 and PR #129 be merged first to ensure proper function.
Checklist
Ensure you completed all of the steps below before submitting your pull request:
forge snapshot
?pnpm gas-report
?pnpm lint
?forge test
?pnpm verify
?